#pragma once

#include <QtWidgets/QWidget>
#include <set>
#include <atomic>
#include "TmsMap/TmsMapTool.h"
#include "Target/data_interface.h"
#include "TmsMap/widget_show_base.h"
#include "boost/shared_ptr.hpp"

using namespace MST_MAP_TOOL;
class target_draw_base;

class QtRadarBDisplay : public QWidget, public WidgetShowBase
{
    Q_OBJECT

public:
    QtRadarBDisplay(QWidget *parent = 0);
    ~QtRadarBDisplay();

    void paintPlot(QPainter& painter);

    virtual Lnglat Screen2LngLat(QPointF pos, bool is_need_change =true);
    virtual QPointF LngLat2Screen(Lnglat lnglat, bool is_need_change = true);

    void paintAllTarget(QPainter &painter);
    virtual bool IsVisibleLnglat(Lnglat lnglat) { return true; }
    virtual double CurrentScale() { return 1001; }
    virtual int GetMapKey() { return MAIN_MAP_KEY; };

    void SetDrawColor(TARGET_TYPE type, QColor color, QColor track_color);
public slots:
    void SetSelectedTarget(info_keys key);
    void SetTargetColor(QColor color, unsigned int target_type, unsigned int color_set_type);

protected:
    virtual void paintEvent(QPaintEvent *event);
    virtual void resizeEvent(QResizeEvent* event);
    virtual void mouseMoveEvent(QMouseEvent *event);
private:
    void initAllRanges();

Q_SIGNALS:
    void mouseLocation(double, double);
    void select_target(const info_keys &key);
private:
    QTimer * update_timer_;

    std::set<int> all_ranges_;
    double range_meters_;
    size_t spoke_len_;

    std::atomic<double> pixel_per_meters_;
    std::atomic<double> pixel_per_azimuth_;

    boost::shared_ptr<target_draw_base> radar_target_draw_;
};
